package com.example.train.business.controller.admin;

import com.example.train.business.req.Daily_TrainStationQueryReq;
import com.example.train.business.req.Daily_TrainStationSaveReq;
import com.example.train.business.resp.Daily_TrainStationQueryResp;
import com.example.train.business.service.Daily_TrainStationService;
import com.example.train.common.resp.CommonResp;
import com.example.train.common.resp.PageResp;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/daily_TrainStation")

public class Daily_TrainStationAdminController {

    @Resource
    private Daily_TrainStationService daily_TrainStationService;

    /**
     * 乘客注册请求的controller类，用于调用service
     * 注意PostMapping必须要用requestBody注解，否则后端接受不到数据
     * @param daily_TrainStationSaveReq
     * @return
     */
    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody Daily_TrainStationSaveReq daily_TrainStationSaveReq) {
        daily_TrainStationService.save(daily_TrainStationSaveReq);
        return new CommonResp<>();
    }
    /**
     * 查询当前会员下乘客信息列表的controller类，用于调用service
     * 注意GetMapping不用requestBody注解，否则后端接受不到数据
     * @param @VALID Daily_TrainStationQueryReq
     * @return CommonResp<PageResp<Daily_TrainStationQueryResp>>
     */
    @GetMapping("/query-list")
    public CommonResp<PageResp<Daily_TrainStationQueryResp>> queryList(@Valid Daily_TrainStationQueryReq req) {
        PageResp<Daily_TrainStationQueryResp> list = daily_TrainStationService.queryList(req);
        return new CommonResp<>(list);
    }

    /**
     * 删除乘客信息的controller层接口
     * @param id
     * @return CommonResp<Object>
     */
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        daily_TrainStationService.delete(id);
        return new CommonResp<>();
    }

}

